package com.study.packet;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.nio.charset.StandardCharsets;

/**
 * @ClassName: NettyServerPacketHandler
 * @Description:
 * @Date 2024/04/29 17:20
 * @Author songshaoqiu
 **/
public class NettyServerPacketHandler extends SimpleChannelInboundHandler<MessageProtocol> {

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, MessageProtocol messageProtocol) throws Exception {
        System.out.println("-----服务端接收到消息--------");
        System.out.println("消息长度:"+messageProtocol.getLength());
        System.out.println("消息内容:"+new String(messageProtocol.getContent(), StandardCharsets.UTF_8));
    }
}
